#pragma once

#include <iostream>
#include <sys/epoll.h>

class Epoll
{
public:
    static const int gsize = 256;
public:
    static int CreateEpoll()
    {
        int epfd = epoll_create(gsize);
        if (epfd > 0) return epfd;
        exit(5);
    }

    static bool CtlEpoll(int epfd, int op, int fd, uint32_t events)
    {
        struct epoll_event ev;
        ev.events = events;
        ev.data.fd = fd;
        int n = epoll_ctl(epfd, op, fd, &ev);
        return n == 0;
    }

    static int WaitEpoll(int epfd, struct epoll_event revs[], int num, int timeout)
    {
        return epoll_wait(epfd, revs, num, timeout);
    }
};